package com.controller.user;

import com.entity.Job;
import com.entity.Resume;
import com.service.CompanyService;
import com.service.UserService;
import com.service.impl.CompanyServiceimpl;
import com.service.impl.UserServiceimpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/AddResume")
public class AddResume extends HttpServlet {
    //    AdminService adminService=new AdminServiceimpl();
    UserService userService=new UserServiceimpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        String userId = req.getParameter("userId");
        String jobId = req.getParameter("jobId");
        String description = req.getParameter("description");
        String src = req.getParameter("src");


        Resume resume = new Resume();
        resume.setAuditState("未审批");
        resume.setDescription(description);
        resume.setJobId(Integer.parseInt(jobId));
        resume.setSrc(src);
        resume.setUserId(userId);


        System.out.println("addresume = " + resume);
        int addi = userService.AddResume(resume);
        System.out.println("addresumei = " + addi);
        if(addi==1){
            resp.getWriter().write("success");
        }else{
            System.out.println(" error" );
            resp.getWriter().write("error");
        }
    }
}
